/*
 * Copyright (C) 2010-2014 Enrique Lara (enrique.posix2.lara@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package trs.wmata;

import android.content.Context;
import android.content.Intent;

import app.transittool.model.Stop;

import app.transittool.provider.Tables.Alarms;

public final class BusStop implements Stop {
    private String code = "UNKNOWN";
    private String name = "UNKNOWN";
    private double lat = -1;
    private double lon = -1;
    private String[] routeCodes = {
                                      "UNKNOWN"
    };
    private final Context context;

    public BusStop(final Context context) {
        this.context = context;
    }

    @Override
    public String getCode() {
        return code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    @Override
    public double getLat() {
        return lat;
    }

    public void setLat(final double lat) {
        this.lat = lat;
    }

    @Override
    public double getLon() {
        return lon;
    }

    public void setLon(final double lon) {
        this.lon = lon;
    }

    @Override
    public String[] getRouteCodes() {
        return routeCodes;
    }

    public void setRouteCodes(final String[] routeCodes) {
        this.routeCodes = routeCodes;
    }

    @Override
    public String[] getRouteNames() {
        return getRouteCodes();
    }

    @Override
    public boolean gotoView() {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.putExtra(Alarms.AGENCY_ID, BusAgency.WMATA_BUS_AGENCY_ID);
        intent.putExtra(Alarms.STOP, getCode());
        intent.setType("application/wmata-nextbus");

        context.startActivity(intent);

        return true;
    }

    @Override
    public boolean gotoViewNearbyStops() {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.putExtra(Alarms.AGENCY_ID, BusAgency.WMATA_BUS_AGENCY_ID);
        intent.putExtra(Alarms.STOP, getCode());
        intent.setType("application/wmata-nearbybus");

        context.startActivity(intent);

        return true;
    }
}
